package com.design.patterns;

//单利模式-懒汉式
public class Singleton1 {
    private static Singleton1 singleton1 = null;

    private Singleton1 (){

    }

    public static Singleton1 getSingleton1(){

        // 还未实例化--改这种写法效率更高
        if (singleton1 == null) {
            synchronized (Singleton1.class) {
                if (singleton1 == null) {
                    singleton1 = new Singleton1();
                }
            }
        }
        return singleton1;
    }
}
